New to PHP/MySQL - Need help with images
New to PHP/MySQL - Need help with images
am 05.01.2008 23:51:47 von thomas
I'm attempting to make a table with one row and 3 columns holding three =
=
different images. I want each image URL to be called from my database. =
Everything is set-up in my database. When I use the following code, it =
places the same picture across the three columns and does this three tim=
es =
(creating three rows.) I want a different picture to be placed across th=
e =
three columns and to have only one row. What can I do?
Here is the code:
$result =3D @mysql_query('SELECT image FROM specials');
$num=3Dmysql_numrows($result);
$i =3D 0;
while ($i < $num) {
$image=3Dmysql_result($result,$i,"image");
?>
";
?>
-- =
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: New to PHP/MySQL - Need help with images
am 06.01.2008 01:07:40 von Matt Anderton
------=_Part_31909_29968595.1199578060301
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
how about like this:
echo "
\n";
$result = @mysql_query("SELECT image FROM specials");
while($row = mysql_fetch_row($result)) {
echo " | \n";
}
echo "
\n
\n";
hope it helps!
matt
On Jan 5, 2008 4:51 PM, Thomas wrote:
> I'm attempting to make a table with one row and 3 columns holding three
> different images. I want each image URL to be called from my database.
> Everything is set-up in my database. When I use the following code, it
> places the same picture across the three columns and does this three times
> (creating three rows.) I want a different picture to be placed across the
> three columns and to have only one row. What can I do?
>
> Here is the code:
>
> $result = @mysql_query('SELECT image FROM specials');
> $num=mysql_numrows($result);
> $i = 0;
> while ($i < $num) {
> $image=mysql_result($result,$i,"image");
> ?>
>
>
>
> ">
> |
>
> ">
> |
>
> ">
> |
>
>
> $i++;
> }
> echo "
";
> ?>
>
> --
> Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
------=_Part_31909_29968595.1199578060301--
Re: New to PHP/MySQL - Need help with images
am 06.01.2008 23:55:49 von dmagick
Thomas wrote:
> I'm attempting to make a table with one row and 3 columns holding three
> different images. I want each image URL to be called from my database.
> Everything is set-up in my database. When I use the following code, it
> places the same picture across the three columns and does this three
> times (creating three rows.) I want a different picture to be placed
> across the three columns and to have only one row. What can I do?
> Here is the code:
>
> $result = @mysql_query('SELECT image FROM specials');
You're only querying one database field here. If you want more than one
image to be loaded from the database, you need to include more fields.
So you'll end up with something like this:
$query = "select image1, image2, image3 from specials";
$result = mysql_query($query);
echo '
';
while ($row = mysql_fetch_assoc($result)) {
echo '';
echo '' . $row['image1'] . ' | ';
echo '' . $row['image2'] . ' | ';
echo '' . $row['image3'] . ' | ';
echo '
';
}
echo '
';
?>
--
Postgresql & php tutorials
http://www.designmagick.com/
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Help with MySql float
am 17.02.2008 16:59:41 von Velen
Hi Guys,
When inserting a value like 123567.8956 in my table it is rounding it to 2
decimal place. The field type is set as float.
Can anyone tell me why it's not taking all the decimals? and How to insert
the number with all the decimals?
Thanks
Velen
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Help with MySql float
am 17.02.2008 17:22:09 von lists.zxinn
Velen wrote:
> Hi Guys,
>
> When inserting a value like 123567.8956 in my table it is rounding it to 2
> decimal place. The field type is set as float.
>
> Can anyone tell me why it's not taking all the decimals? and How to insert
> the number with all the decimals?
>
> Thanks
>
> Velen
>
>
Hello Velen,
Your question seem purely related to MySQL. Not very PHP related. Anyway...
It depends on your version of MySQL. Check the documentation for Numeric
Types. It says you can specify the number of decimals you want to store,
something like FLOAT(max_digits,precision). If you need more precision,
there's also the DOUBLE PRECISION.
If your MySQL column is specified for higher precision already, then it
could be a PHP issue. Is this the case?
For MySQL => 5.0
http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html
For MySQL < 5.0
http://dev.mysql.com/doc/refman/4.1/en/numeric-types.html
/Tobias
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Help with MySql float
am 17.02.2008 18:29:03 von parasane
On Feb 17, 2008 10:59 AM, Velen wrote:
> Hi Guys,
>
> When inserting a value like 123567.8956 in my table it is rounding it to 2
> decimal place. The field type is set as float.
>
> Can anyone tell me why it's not taking all the decimals? and How to insert
> the number with all the decimals?
That's a MySQL question, not a PHP question, but my guess is that
the column is set as FLOAT(x,2) (where x is any real number). Try
changing that to FLOAT(10,4). The first number is everything to the
left of the decimal, while the second is the number of places to count
after the decimal.
--
Daniel P. Brown
Senior Unix Geek
while(1) { $me = $mind--; sleep(86400); } ?>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Help with MySql float
am 18.02.2008 00:12:03 von dmagick
Daniel Brown wrote:
> On Feb 17, 2008 10:59 AM, Velen wrote:
>> Hi Guys,
>>
>> When inserting a value like 123567.8956 in my table it is rounding it to 2
>> decimal place. The field type is set as float.
>>
>> Can anyone tell me why it's not taking all the decimals? and How to insert
>> the number with all the decimals?
>
> That's a MySQL question, not a PHP question, but my guess is that
> the column is set as FLOAT(x,2) (where x is any real number). Try
> changing that to FLOAT(10,4). The first number is everything to the
> left of the decimal, while the second is the number of places to count
> after the decimal.
Also note that a float type is not guaranteed to come back the same as
it goes in (and this will also affect maths operations) - so if you need
4 decimal places, then use decimal or numeric as the data type.
http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html
MySQL performs rounding when storing values, so if you insert 999.00009
into a FLOAT(7,4) column, the approximate result is 999.0001.
The DECIMAL and NUMERIC data types are used to store exact numeric data
values. ..... These types are used to store values for which it is
important to preserve exact precision, for example with monetary data.
This is the same in any db, it's not a mysql specific behaviour.
--
Postgresql & php tutorials
http://www.designmagick.com/
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php